package com.bjesc_b2c.app.appraiset.mvp.model.impl;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.http.IApiActivityRequest;
import com.bjesc_b2c.app.appraiset.mvp.model.GetCarForModel;
import com.rxretrofit_build.util.MapUtil;

import java.util.HashMap;
import java.util.List;

import master_bean.CarForBean;
import rxretrofit_base.model.ShowType;
import rxretrofit_base.model.TokenBean;
import rxretrofit_base.net.BaseSubscriber;
import rxretrofit_base.net.RxRequest;


/**
 * Created by lenovo on 2017/4/22.
 */

public class GetCarForModelImpl implements GetCarForModel{
    private CallBack callBack;
    public GetCarForModelImpl(CallBack callBack){
        this.callBack = callBack;

    }
    @Override
    public void requestCarFor(Context context,String marketID) {
        HashMap<String,Object> build = new MapUtil()
                .put("market_id",marketID)
                .build();

        RxRequest.request(ShowType.SHOW, RxRequest.getClient(context, build).create(IApiActivityRequest.class).getDealer(),
                new BaseSubscriber<TokenBean<List<CarForBean>>>(context) {
                   @Override
                    public void onSuccess(TokenBean<List<CarForBean>> o) {
                        callBack.callback(o.getData());
                    }
                    @Override
                    public void onFailure(Throwable e) {

                    }
                });
    }
    public interface CallBack{
        void callback(List<CarForBean> listbean);
    }
}
